// pages/sarchList/index.js
const app = getApp()
var page = 1;
var pagesize = 12;
var type;
var key;
Page({

  /**
   * 页面的初始数据
   */
  data: {
    userList:[],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    console.log('接收参数', options)
    type = options.type;
    key = options.key;
    this.setData({
      key: key
    })
    this.getSearchUserList();
  },
  goVisitorInfo: function (e) {
    console.log('传递信息', e.currentTarget.id)
    var id = e.currentTarget.id;
    wx.navigateTo({
      url: '../visitorInfo/index?id=' + id
    })
  },
  //搜索用户列表
  getSearchUserList: function () {
    console.log('椰树', page)
    var that = this;
    var data = [];
    data['page'] = page;
    data['pagesize'] = pagesize;
    data['type'] = type;
    data['key'] = key;
    var url = 'We_Community/getSearchUserList';
    var calkdata = app.netWorkRequest(that, data, url, 'userList')
  },
  //加载更多用户列表
  getSearchUserListLoadMore: function () {
    console.log('椰树', page)
    var that = this;
    var data = [];
    // 页数+1
    page = page + 1;
    data['page'] = page;
    data['pagesize'] = pagesize;
    data['type'] = type;
    data['key'] = key;
    var url = 'We_Community/getSearchUserList';
    var f_data = that.data.userList;
    var calkdata = app.netWorkRequestLoadMore(that, data, url, 'userList', f_data);
  },
  getSarchInterface: function () {
    wx.navigateTo({
      url: '../sarch/index'
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    page = 1;
    this.getSearchUserList();
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
    wx.showLoading({
      title: '玩命加载中',
    })
    this.getSearchUserListLoadMore();
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})